﻿using Dapper;
using DapperExtensions;
using Domain.Sys;
using Infrastructure.Dapper;
using IRepository.Sys;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Repository.Sys
{
    public class AdminUserRepository : RepositoryBase<AdminUser>, IAdminUserRepository
    {

        public async Task<AdminUser> GetByUserNameAsync(string username)
        {
            var sql = "SELECT * FROM AdminUser WHERE UserName = @UserName AND IsDelete = 0";

            using (IDbConnection conn = ConnectionFactory.CreateSqlConnection())
            {
                return await conn.QueryFirstOrDefaultAsync<AdminUser>(sql, new { UserName = username });
            }
        }
    }
}
